package com.ketangpai.service.impl;


import com.ketangpai.entity.Course;
import com.ketangpai.entity.response.BaseResponse;
import com.ketangpai.mapper.CourseMapper;
import com.ketangpai.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.awt.*;
import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    CourseMapper courseMapper;

    BaseResponse baseResponse=new BaseResponse<>();

    @Override
    public boolean addCourse(Course course) {
        return courseMapper.addCourse(course) > 0;
    }

    @Override
    public int SuccessAddCourse(Course course){
        return courseMapper.SuccessAddCourse(course);
    }

    @Override
    public Course getCourseById(String id) {
        return courseMapper.getCourseById(id);
    }

    @Override
    public List<Course> showCourse(String id) {
        return courseMapper.showCourse(id);
    }

    @Override
    public List<Course> getAllCourse(String teacherId) {
        return courseMapper.getAllCourse(teacherId);
    }

    @Override
    public List<String> getStuMember(String courseId) {
        return courseMapper.getStuMember(courseId);
    }

    @Override
    public List<String> getTeaMember(String courseId) {
        return courseMapper.getTeaMember(courseId);
    }

    @Override
    public Image getBGimg(String courseId){
        return courseMapper.getBGimg(courseId);
    }

    @Override
    public String getStatus(String account, String courseId){
        return courseMapper.getStatus(account,courseId);
    }

    @Override
    public String delCourse(String courseId, String manager) {
        try {
            return courseMapper.delCourse(courseId,manager);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public String dropStudent(String account, String courseId) {
        try {
            return courseMapper.dropStudent(account,courseId);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

}
